package com.os.osframe.scaffold.domain;

import javax.xml.bind.annotation.*;
import java.util.List;

/**
 * Created by wangdc on 2015-4-26.
 */
@XmlAccessorType(XmlAccessType.FIELD)
public class ScaffoldXmlTable {
    @XmlAttribute(name="name" )
    protected String tableName;//表名
    @XmlAttribute(name="info" )
    protected String tableInfo;//描述
    @XmlAttribute
    protected String status;//状态

    @XmlElementWrapper(name="fields" )
    @XmlElements(@XmlElement(name="field", type=ScaffoldXmlField.class))
    protected List<ScaffoldXmlField> scaffoldXmlFieldList;//字段列表

    public String getTableName() {
        return tableName;
    }

    public void setTableName(String tableName) {
        this.tableName = tableName;
    }

    public String getTableInfo() {
        return tableInfo;
    }

    public void setTableInfo(String tableInfo) {
        this.tableInfo = tableInfo;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public List<ScaffoldXmlField> getScaffoldXmlFieldList() {
        return scaffoldXmlFieldList;
    }

    public void setScaffoldXmlFieldList(List<ScaffoldXmlField> scaffoldXmlFieldList) {
        this.scaffoldXmlFieldList = scaffoldXmlFieldList;
    }

    /**
     * 获取domain
     * @return
     */
    public String getDomain() {
        String javaName="";
        String[] tableArr=tableName.split("_");
        for(int i=0;i<tableArr.length;i++){
            javaName+=tableArr[i].substring(0, 1).toUpperCase()+tableArr[i].substring(1);;
        }
        return javaName;
    }
    /**
     * 获取对象名
     * @return
     */
    public String getJavaName() {
        String javaName=this.getDomain();
        javaName=javaName.substring(0, 1).toLowerCase()+javaName.substring(1);
        return javaName;
    }

}
